package io;

import java.io.*;

/**
 * @description: ToDo
 * @author: marin
 * @time: 2020/7/2 13:55
 */
public class ImageInput {
    public static void main(String[] args) throws IOException {

        long start = System.currentTimeMillis();
        File file = new File("./timg.jpg");
        FileInputStream inputStream = new FileInputStream(file);
        FileOutputStream fileOutputStream = new FileOutputStream("test1.jpg");

        //转换字节的个数
        int len=0;
        //使用字节缓冲数组，一次写入1024个字节
        byte[] bytes = new byte[1024];
        while ((len=inputStream.read(bytes))!= -1) {
            System.out.println("len:");
            //读取五个，只转换五个
            fileOutputStream.write(bytes,0,len);
        }

        //按行读取
       /* while((len=inputStream.read()) != -1){
            fileOutputStream.write(len);
        }*/
        long end = System.currentTimeMillis();
        System.out.println("花费时间："+(end-start)+"ms");
        inputStream.close();
        fileOutputStream.close();
    }
}
